<html>
	<head>
		<script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
		<script language="JavaScript" type="text/javascript" src="../../jsmock.js"></script>
		<script language="JavaScript" type="text/javascript" src="../helpers.js"></script>
		<script language="JavaScript" type="text/javascript">
			//
			// HELPERS
			//
			function getArgumentsObject() {
				return arguments;
			}

			function SomeNamedFunction() 
			{}

			function FunctionWithArgs(snap, peas, and, carrots)
			{}

			//
			// TESTS
			//
			function test_format_simple()
			{
				args = getArgumentsObject(1);
				assertEquals("1", ArgumentFormatter.format(args));

				args = getArgumentsObject("yum");
				assertEquals("\"yum\"", ArgumentFormatter.format(args));

				args = getArgumentsObject(3, "Gosh!");
				assertEquals("3, \"Gosh!\"", ArgumentFormatter.format(args));

				date = new Date();
				args = getArgumentsObject(date);
				assertEquals(date.toString(), ArgumentFormatter.format(args));
			}

			function test_format_arrays() {
				args = getArgumentsObject(["superman", "batman", 1.3]);
				assertEquals("[\"superman\", \"batman\", 1.3]", ArgumentFormatter.format(args));

				args = getArgumentsObject("croz", [1, 5]);
				assertEquals("\"croz\", [1, 5]", ArgumentFormatter.format(args));

				args = getArgumentsObject([6, 7, ["h", "a", "b", ["agile", "scrum?"]], 0, 0]);
				assertEquals("[6, 7, [\"h\", \"a\", \"b\", [\"agile\", \"scrum?\"]], 0, 0]", ArgumentFormatter.format(args));
			}

			function test_format_typeof() {
				args = getArgumentsObject(TypeOf.isA(Array), TypeOf.isA(Date));
				assertEquals("Array, Date", ArgumentFormatter.format(args));
				
				args = getArgumentsObject(TypeOf.isA(Function));
				assertEquals("Function", ArgumentFormatter.format(args));
			}

			function test_format_native_function() {
				args = getArgumentsObject(Array, Date, Object, String, Function, RegExp, Error, Number, Boolean);
				assertEquals("Array, Date, Object, String, Function, RegExp, Error, Number, Boolean", ArgumentFormatter.format(args));
			}

			function test_format_functions() {
				args = getArgumentsObject(SomeNamedFunction);
				assertEquals("SomeNamedFunction", ArgumentFormatter.format(args));

				args = getArgumentsObject(FunctionWithArgs);
				assertEquals("FunctionWithArgs", ArgumentFormatter.format(args));

				args = getArgumentsObject(function() {});
				assertEquals("{{Closure}}", ArgumentFormatter.format(args));

				args = getArgumentsObject(function(hello,goodbye) {});
				assertEquals("{{Closure}}", ArgumentFormatter.format(args));
			}

			function test_format_null() {
				args = getArgumentsObject(null);
				assertEquals("null", ArgumentFormatter.format(args));
			}

			function test_format_no_args() {	
				args = getArgumentsObject();
				assertEquals("", ArgumentFormatter.format(args));
			}

		</script>
	</head>
	<body>
		<p>ArgumentFormatterTest</p>
	</body>
</html>
